export const routers = [
    {
        path: '/',
        redirect: "/home"
    },
    {
        path: '/center',
        redirect: '/center/mypaylist'
    },
    {
        path: '/home',
        name: 'home',
        meta: {
            titel: '主页'
        },
        component: () => import('@/components/Home/Home.vue')
    },
    {
        path: '/regist',
        name: 'regist',
        meta: {
            titel: '注册',
            showNav: true
        },
        component: () => import('@/Pages/Regist/Regist.vue')
    },
    {
        path: '/search',
        name: 'search',
        component: () => import('@/Pages/Search/Search.vue'),
        meta: {
            asyncTitel: true
        },
    },
    {
        path: '/login',
        name: 'login',
        meta: {
            titel: '登录',
            showNav: true
        },
        component: () => import('@/Pages/Login/Login.vue')
    },
    {
        path: '/detail',
        name: 'detail',
        meta: {
            asyncTitel: true,
            titel: '商品详情页',
            check: true
        },
        component: () => import('@/Pages/Detail/Detail.vue'),

    },
    {
        path: '/cartsuceess',
        name: 'success',
        component: () => import('@/Pages/AddCartSuccess/index.vue'),
        meta: {
            asyncTitel: true,
            titel: '添加购物车成功',
        },
        beforeEnter: (_: any, from: any) => {
            if (from.name && from.name == 'detail') {
                return true
            }
            return false
        },

    },
    {
        path: '/shopcart',
        name: 'shopcart',
        component: () => import('@/Pages/ShopCart/ShopCart.vue'),
        meta: {
            asyncTitel: true,
            titel: '购物车',
        }
    },
    {
        path: '/trade',
        name: 'trade',
        meta: {
            asyncTitel: true,
            titel: '确认订单',
        },
        component: () => import('@/Pages/Trade/Trade.vue'),
        beforeEnter: (_: any, from: any) => {
            if (from.name && from.name == 'shopcart') {
                return true
            }
            return false
        },
    },
    {
        path: '/pay',
        name: 'pay',
        meta: {
            asyncTitel: true,
            titel: '支付',
        },
        component: () => import('@/Pages/Pay/Pay.vue'),
        beforeEnter: (_: any, from: any) => {
            if (from.name && from.name == 'trade') {
                return true
            }
            return false
        },
    },
    {
        path: '/success',
        name: 'successPay',
        meta: {
            asyncTitel: true,
            titel: '恭喜您支付成功',
        },
        component: () => import("@/Pages/PaySuccess/index.vue"),
        beforeEnter: (_: any, from: any) => {
            if (from.name && from.name == 'pay') {
                return true
            }
            return false
        },
    },
    {
        path: '/center',
        name: 'center',
        meta: {
            asyncTitel: true,
            titel: '订单中心',
        },
        component: () => import("@/Pages/Center/index.vue"),
        children: [
            {
                path: 'mypaylist',
                name: 'mypaylist',
                meta: {
                    asyncTitel: true,
                    titel: '我的订单中心',
                },
                component: () => import("@/Pages/MyPayList/index.vue"),
            },
            {
                path: 'teamlist',
                name: 'teamlist',
                meta: {
                    asyncTitel: true,
                    titel: '团购中心',
                },
                component: () => import("@/Pages/Team/index.vue"),
            }
        ]
    }
]
